%module function
%include std_complex.i
%include std_string.i
%include std_vector.i
%include typemaps.i

%exception Spin {
   try {
      $action
   } catch (std::out_of_range &e) {
      PyErr_SetString(PyExc_ValueError, const_cast<char*>(e.what()));
      return NULL;
   }
}

%exception _BuildFromDouble {
   try {
      $action
   } catch (std::out_of_range &e) {
      PyErr_SetString(PyExc_ValueError, const_cast<char*>(e.what()));
      return NULL;
   }
}


%exception _Wigner_d {
  try {
    $action
  } catch (std::domain_error &e) {
    PyErr_SetString(PyExc_ValueError, const_cast<char*>(e.what()));
    return NULL;
  }
}

%exception _BlattWeisskopf {
  try {
    $action
  } catch (std::domain_error &e) {
    PyErr_SetString(PyExc_ValueError, const_cast<char*>(e.what()));
    return NULL;
  }
}

%{
#include "function.hpp"
#include "Spin.hpp"
%}

%template(LSVector) std::vector<LS>;

%ignore *::operator=;
%ignore *::operator();
%ignore *::operator[];
%ignore *::operator++;
%ignore *::operator--;

%ignore operator<<(std::ostream &__os, const Spin &__spin);
%rename(__str__) Spin::ToString() const;
%rename(__float__) Spin::operator double() const;

%include "Spin.hpp"

%include "function.hpp"
